<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<script src="/js/axios.js"></script>
		<script src="/js/vue.js"></script>
		<script src="/js/element-ui/index.js"></script>
		<link rel="stylesheet" type="text/css" href="/js/element-ui/index.css" />
		<title>登录</title>
	</head>
	<body style="background-image: url(/image/background.png);background-size: 100%;">
		<div id="box">
			<el-form :model="user" label-position="left">
				<el-form-item label="账号">
					<el-input style="width: 17vw;height: 15px;" v-model="user.username"></el-input>
				</el-form-item>
				<el-form-item label="密码">
					<el-input style="width: 17vw;height: 15px;" v-model="user.password" show-password></el-input>
				</el-form-item>
			</el-form>
			<span slot="footer" style="margin-left: 3vw;">
				<el-button @click="cencel()">取 消</el-button>
				<el-button type="primary" @click="login()">确 定</el-button>
			</span>
		</div>
	</body>
	<script>
		new Vue({
			el: "#box",
			data: {
				user: {
					username: "adm",
					password: "123456"
				}
			},
			methods: {
				cencel() {
					window.location.href = "/";
				},
				login() {
					let _this = this
					axios({
						url: "/doLogin",
						method: "post",
						headers: {
							'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
						},
						params: this.user
					}).then(function(response) {
						if (response.data.status == 200) {
							let me = response.data.user
							if(me.role=='A'){
								window.location.href = "/api/adm/manager/go2Manager"
							}else{
								window.location.href = "/"
							}
						} else {
							_this.$message({
								message: "登陆失败,账号或密码不正确",
								showClose: 'true',
								type: 'error'
							})
						}
					})
				}
			}
		})
	</script>
	<style>
		#box {
			margin-top: 25vw;
			margin-left: 37vw;
		}
	</style>
</html>
